package com.example.senior_bug.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

//生成订单UUID类(订单UUID应全由数字组成)
public class OrderUUIDUtils {
    private static int number;
    private static int maxNum = 200000;
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");//年月日格式

    public static String createUUID() {
        String uuid = UUID.randomUUID().toString();
        return uuid.replaceAll("-", "");
    }

    public static String createOrderId() {
        number++;
        if (number >= maxNum) {
            number = maxNum - 200000;
        }
        return sdf.format(new Date()) + number;
    }
}
